<?php

//kalau mau mengubah FM ini, harus diubah juga di config/config.php
//default adalah MY
class Kecamatan_model extends FM_Model
{
  /**
  Fungsi ini berguna untuk membuat form_dropdown
Array
(
    [1] => Bukit Raya
    [2] => Lima Puluh
    [3] => Marpoyan Damai
    [4] => Payung Sekaki
    [5] => Pekanbaru Kota
    [6] => Rumbai
    [7] => Rumbai Pesisir
    [8] => Sail
    [9] => Senapelan
    [10] => Sukajadi
    [11] => Tampan
    [12] => Tanayan Raya
)
  */
  public function getAllIDNama(){
    $this->db->select('id,nama');
    $result =  $this->db->get($this->_table)->result();
    $result_ar = array();
    foreach ($result as $row){
      //array_push($result_ar,array($row->id,$row->nama));
      $result_ar[$row->id] = $row->nama;
    }
    return $result_ar;
  }

  public function getAllKelurahanAsObject($id){
    $this->db->select('id,nama');
    $this->db->where('id_kecamatan',$id);
    return $this->db->get('kelurahan')->result();
  }
  public function getAllKelurahanAsArray($id){
    $o = $this->getAllKelurahanAsObject($id);

    $result_ar = array();
    foreach ($o as $row){
      //array_push($result_ar,array($row->id,$row->nama));
      $result_ar[$row->id] = $row->nama;
    }
    return $result_ar;
  }
}